package org.springsecuritylearn.repository.jvm.lession1.demo1;

/**
 * 此对象可复活
 *
 * @author hyf
 * @Title: ${file_name}
 * @Package org.springsecuritylearn.repository.jvm.lession1.demo1
 * @Description: ${todo}
 * @date 2018/5/2下午11:39
 */
public class CanReliveObj {
    public static CanReliveObj canReliveObj;

    @Override
    protected void finalize() throws Throwable {
        super.finalize();
        System.out.println("CanReliveObj finalize called");
        canReliveObj=this;
    }

    @Override
    public String toString() {
        return "I am CanReliveObj";
    }

    public static void main(String[] args) throws InterruptedException {
        canReliveObj=new CanReliveObj();
        canReliveObj=null;
        System.gc();
        Thread.sleep(3000);
        if (canReliveObj==null){
            System.out.println("1 canReliveObj is null");
        }else {
            System.out.println("1 canReliveObj is not null");
        }
        canReliveObj=null;
        System.gc();
        Thread.sleep(3000);
        if (canReliveObj==null){
            System.out.println("2 canReliveObj is null");
        }else {
            System.out.println("2 canReliveObj is not null");
        }





    }
}
